<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta name="description" content=""/>
	<meta name="keywords" content=""/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
	<title>Ajax 登录</title>
	<link rel="stylesheet" type="text/css" th:href="@{/css/login/reset.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/css/login/common.css}" media="all"/>
	<link rel="stylesheet" type="text/css" th:href="@{/css/login/zxx.lib.css}" media="all"/>
	<link rel="stylesheet" type="text/css" th:href="@{/css/login/portal.css}" media="all"/>
</head>
<body class="oscar-bg">
<div id="app" class="oscar-content rel">
	<div class="oscar-content-inside rel">
		<h1 class="oscar-title fix">
			<img class="l" style="margin-top:7px;" th:src="@{/css/images/logo.png}" height="26px" width="auto" />
			<div class="l">&nbsp;TDD智能日报系统</div>
		</h1>
	</div><!-- oscar-content-inside -->
	<div class="oscar-login-box abs">
		<span id="context" th:value="@{/}" hidden></span>
		<form name="form"  method="POST" onsubmit="return false;">
			<input class="oscar-username oscar-text db" id="username"  v-model="username" name="username" type="text"  placeholder="请输入用户名"/>
			<input class="oscar-password oscar-text db" id="password"  v-model="password"  name="password" type="password" placeholder="请输入密码"/>
			<button id="loginBtn"  type="button" class="oscar-submit db" @click="login" >登&nbsp;&nbsp;&nbsp;&nbsp;录</button>
		</form>
		<!--<span hidden id="error" style="font:bold;color:red" th:text="${#request.getParameter('error')}"/>-->
	</div><!-- /oscar-login-box -->
	<input class="oscar-password oscar-text db" id="cors"  name="password" type="button" value="cors" />
	{{username}},{{password}}
</div><!-- /oscar-content -->
<footer class="oscar-footer">
	<div class="oscar-line auto"></div><!-- /oscar-line -->
	<br />
	<div class="tc f14 oscar-info">
		Powered by：技术发展部
	</div>
</footer>
<script th:src="@{/venders/jquery/jquery.min.2.1.4.js}"></script>
<script th:src="@{/venders/vue.js}"></script>
<script th:src="@{/venders/vue-resource-1.3.4.js}"></script>
<script th:src="@{/lib/base64.js}"></script>
<script th:src="@{/lib/keter-common.js}"></script>
</body>
<script>
	//---- your code begin ----//
            /*用户列表*/
			var userTable = new Vue({
					el : '#app',
					data : {
					    username:""   //账号
					   ,password:""
					},
					created: function () {

				    },
				    methods:{
				       login:function(){
				        var vm = this;
						vm.$http.post('/authenticate', {username:username.value,password:password.value})
						    .then(function(response){
						    <!--console.log(response.data.token);-->
							// 响应成功回调
							keter.setToken(response.data.token);
                            window.location.href= "/ajax/home";
						}, function(response){
							// 响应错误回调
						});
				       }
				    }
				});

	   $("#cors").click(function(){
	      $.ajax({
					url: "http://localhost:8888/public/cors",
					contentType: "application/json",
					method: 'GET',
					success: function (data) {
						alert(data);
					}
			});
	   });

</script>
</html>
